﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>添加角色</title>
     <link href="../css/main.css" rel="stylesheet" type="text/css" />
    <link href="../css/Jqbox.css" rel="stylesheet" type="text/css" />
    <link href="../css/jquery.loadmask.css" rel="stylesheet" type="text/css" />
    <script src="../Js/jquery-1.5.2.min.js" type="text/javascript"></script>
    <script src="../Js/ligerui.min.js" type="text/javascript"></script>
    <script src="../Js/jquery.dialog.js" type="text/javascript"></script>
    <script src="../Js/jquery.loadmask.min.js" type="text/javascript"></script>
    <script src="../Js/json2.js" type="text/javascript"></script>
    <script src="../Js/conmon.js" type="text/javascript"></script>
    <script type="text/javascript">
        var Row = null;
        var pWind = null;
        var A_ID = 0;
        $(function () {
            $("#from1").ligerForm();
            //$selectRow
            pWind = parent.window.parent.window.getWindow();


            loadList(0);

            //保存
            $("#btnSave").click(function () {
                if (chk()) {
                    var pars = { name: $("#txtName").val(), rmark: $("#txtRemark").val() };
                    $("body").mask("数据处理中，请稍候......");
                    $.post('../WebServer/RoleMange.ashx?Action=SaveRoleItem', pars, function (data) {
                        $("body").unmask();
                        var rdata = eval("(" + data + ")");
                        if (rdata.IsSuccess > 0) {
                            showAlertOk("保存成功");
                            var str = "<option value=\"0\">" + $("#txtName").val() + "</option>";
                            $("#lsEmplist").append(str);

                            $("#txtName").val("")
                            $("#txtRemark").val("")
                        } else {
                            if (rdata.IsSuccess == -99) {
                                showErrorTip("不能保存，已经存在该角色了");
                            } else
                                showErrorTip(rdata.Msg);
                        }
                    });

                } //end chk
            });
            $("#btnCancel").click(function () { closeRefresh(false, ""); });

        });

        function loadList(id) {


            $.getJSON('../WebServer/RoleMange.ashx?Action=RoleList', { areaid: id, Rnd: Math.random() }, function (data) {
                if (data != null) {
                    for (var i = 0; i < data.length; i++) {
                        var str = "<option value=\"" + data[i].id + "\">" + data[i].text + "</option>";
                        $("#lsEmplist").append(str);
                    }

                }

            });
        }
        function chk() {
            var err = "";

            if ($.trim($("#txtName").val()) == "") {
                err = "请输入角色名称!";
                showErrorTip(err);
                return false;
            }

            return true;
        }
      
    </script>

     <style type="text/css">
        .edittable td.editcellmessage,.edittable td.editcellverify,.edittable td.editcell{ padding:5px;line-height:25px;}
        .edittable td.editcellmessage{ padding-left:20px;} 
        body { font-size:12px; background:white;}
         
    </style>
</head>
<body>
<form id="from1" action="">
     <table cellpadding="0" border="0" cellspacing="0" class="edittable">
        <tr>
        
         <td class="editcellmessage" colspan="2">
           <select size="20" style=" width:200px" name="lsEmplist" id="lsEmplist">
           
           </select>

         </td>
         <td valign="top">
                <table cellpadding="0" border="0" cellspacing="0" class="edittable">
                 <tr>
                    <td class="editcellmessage">角色名称</td>
                    <td class="editcellmessage"><input id="txtName" name="txtName" type="text" ltype="text" class="l-textbox" /></td>
                       </tr>
                   <tr>
                    <td class="editcellmessage">备注</td>
                    <td class="editcellmessage">
                     <textarea id="txtRemark" name="txtRemark" cols="100" rows="18" class="l-textarea" style="width:200px"></textarea>
                    </td>
                 </tr>
                </table>
         
         </td>
        </tr>
   </table>
       <div class="buttonpanel">
             <div style="float:right;margin-right:10px;">
                 <a id="btnSave" class="button" href="javascript:void(0);"><span>保存</span></a>
                 <a id="btnCancel" class="button" href="javascript:void(0);"><span>关闭</span></a>
              </div>
      </div>
   </form>
</body>
</html>